import request from '@/utils/request.js'
/**
 * 获取验证码
 * @param {*} mobile  手机号
 * @returns promise
 */
export function getCode (mobile) {
  return request({
    url: '/v1_0/sms/codes/' + mobile
  })
}
/**
 * 登录
 * @param {*} data  {moblie,code}
 * @returns
 */
export function login (data) {
  return request({
    url: '/v1_0/authorizations',
    method: 'POST',
    data
  })
}

/**
 * 获取用户信息
 * @param {*} token 登录存的token
 * @returns
 */
export function getUserSelfInfo () {
  return request({
    url: '/v1_0/user'
  })
}
/**
 *
 * @returns 获取自己的用户频道
 */
export function getUserSelfChannels () {
  return request({
    url: '/v1_0/user/channels'
  })
}
/**
 *
 * @param {*} channel 添加我的频道接口
 * @returns
 */
export function addUserChannelsItem (channel) {
  return request({
    url: '/v1_0/user/channels',
    method: 'PATCH',
    data: {
      channels: [channel]
    }
  })
}
export function removeUserChannelItem (id) {
  return request({
    url: '/v1_0/user/channels/' + id,
    method: 'DELETE'
  })
}
/**
 * 取消用户
 * @param {*} target 要取消用户的 id
 * @returns
 */
export function DeleteTarget (target) {
  return request({
    url: '/v1_0/user/followings/' + target,
    method: 'DELETE'
  })
}
/**
 * 关注用户
 * @param {*} target 关注用户的id
 * @returns
 */
export function PostFollowings (target) {
  return request({
    url: '/v1_0/user/followings',
    method: 'POST',
    data: {
      target: target
    }
  })
}
/**
 * 获取用户个人资料
 * @returns
 */
export function getUserProfile () {
  return request({
    url: '/v1_0/user/profile'
  })
}
// 更新用户个人资料
export function updateUserProfile (data) {
  return request({
    url: '/v1_0/user/profile',
    method: 'PATCH',
    data
  })
}
/**
 * 更新头像
 * @param {*} data
 * @returns
 */
export function updateUserImage (data) {
  return request({
    url: '/v1_0/user/photo',
    method: 'PATCH',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data
  })
}
